<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
<link href="lib/Hui-iconfont/1.0.6/iconfont.css" rel="stylesheet" type="text/css" />
<link href="lib/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
<style>
.rule-con{margin:10px 0px 30px 0px;}
.mleft{margin-left:-150px;}
.wimg{margin-left:-95px;margin-top:-55px;height:90px;width:90px;border:0px solid white;}
.bor{width:740px;height:20px;border-bottom:1px dotted #ccc;}
.gname{width:200px;display:inline-block;margin-left:30px;}
a:hover{text-decoration:none;color:black;}
</style>
<title>推荐分类活动</title>
</head>
<body>
<div class="pd-20">
	<form action="<%=path%>/backstage/addGoodsActType" onsubmit="return false;" method="post" class="form form-horizontal" id="form-t_goods_activity-add">
		<input type="hidden" id="createtime" name="oldtime" value='${actTypeList[0].createtime}' />
		<input type="hidden" id="oldcity" name="oldcity" value='${actTypeList[0].cityid}' /> 
		<c:if test="${empty type2 }">
			<input type="hidden" name="oldtype" value='${type1 }' />
			<input type="hidden" id="chktypeid" name="typeid" value='${type1 }' />
		</c:if>
		<c:if test="${not empty type2 }">
			<input type="hidden" name="oldtype" value='${type2 }' />
			<input type="hidden" id="chktypeid" name="typeid" value='${type2 }' />
		</c:if>

        <div class="row cl">
				
			<label class="form-label col-2">商品分类：</label>
            <div class="formControls col-2">
				<span class="select-box">
				<select class="select" id="type1" onchange="firstChange(this);">
					<option value="">--大类--</option>
					<c:forEach items="${types}" var="bigtype">
					<option value="${bigtype.cCode}" <c:if test="${bigtype.cCode==type1}">selected</c:if> >${bigtype.cName}</option>
					</c:forEach>
				</select>
				</span>
        	</div>
		   <div class="formControls col-2"> <span class="select-box">
				<select class="select" id="type2" onclick="secondClick(this)">
					<option value="-1">--中类--</option>
					<c:forEach items="${types2}" var="twotype">
					<option value="${twotype.cCode}" <c:if test="${twotype.cCode==type2}">selected</c:if> >${twotype.cName}</option>
					</c:forEach>
				</select>
				</span>
		   </div>
		</div>
        <div class="row cl">
			<label class="form-label col-2">所属县市：</label>
			<div class="formControls col-2">
				<span class="select-box">
					<select id="cityid" name="cityid" class="select" datatype="n" nullmsg="请选择县市">
						<c:forEach items="${citys}" var="city">
						<option value="${city.id}" <c:if test="${city.id==actTypeList[0].cityid}">selected</c:if> >${city.name}</option>
						</c:forEach>
					</select>
				</span>
			</div>
        </div>
        <div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>活动位置：</label>
			<div class="formControls col-2">
				<input type="text" class="input-text" value="${actTypeList[0].bigsort }" placeholder="" id="" name="bigsort">
			</div>
        </div>
        <div class="row cl">
			<label class="form-label col-2">是否上线：</label>
			<div class="radio-box">
				  <input type="radio" name="enable" value="0" checked="true" <c:if test='${0==actTypeList[0].enable}'>checked="true"</c:if> >
				  <label for="sex-1">否</label>
				</div>
				<div class="radio-box">
				  <input type="radio"  name="enable" value="1" <c:if test='${1==actTypeList[0].enable}'>checked="true"</c:if> >
				  <label for="sex-2">是</label>
			</div>
        </div>
        <div class="row cl">
			<c:if test="${actTypeList[0].actimg!=null&&actTypeList[0].actimg!=''}">
			<label class="form-label col-2"></label>
			<div class="formControls col-10"><img src="<%=imagePath%>${actTypeList[0].actimg}" width="100" border="0" /></div>
			</c:if>
		</div>
        <div class="row cl" id="uploader">
			<label class="form-label col-2"><span class="c-red">*</span>标题图片：</label>
			<div class="formControls col-5">
				<div class="uploader-thum-container">
					<div id="fileList" class="uploader-list"></div>
					<div id="filePicker">选择图片</div>
					<button id="btn-star" type="button" class="btn btn-default btn-uploadstar radius ml-10" style="display: none">开始上传</button>			
				</div>
			</div>
		</div>
		<div class="row cl">
			<c:if test="${actTypeList[0].acturlimg!=null&&actTypeList[0].acturlimg!=''}">
			<label class="form-label col-2"></label>
			<div class="formControls col-10"><img src="<%=imagePath%>${actTypeList[0].acturlimg}" width="100" border="0" /></div>
			</c:if>
		</div>
		<div class="row cl">
			<label class="form-label col-2">链接图片：</label>
			<div class="formControls col-10">
				<div class="uploader-thum-container">
					<div id="fileList2" class="uploader-list"></div>
					<div id="filePicker2">选择图片</div>
					<button id="btn-star2" type="button"  class="btn btn-default btn-uploadstar radius ml-10" style="display: none"></button>
				</div>
			</div>
		</div>
        <div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>链接：</label>
			<div class="formControls col-4">
				<input type="text" class="input-text" value="${actTypeList[0].url }" placeholder="" id="" name="url">
			</div>
        </div>
		<input type="hidden" id="urlimg" name="urlimg" value="${actTypeList[0].acturlimg}" />
		<input type="hidden" id="image" name="img" value="${actTypeList[0].actimg}" />
		<input type="hidden" id="products_list" name="products_list" value="" />
		</form>
		<div class="row cl info-con to-top mt-20 mb-20">
				<label class="form-label col-2"><span style="float:right;margin-right:10px;" class="hr-info">活动商品：</span></label>
				<div class="formControls col-3">
					<a class="btn btn-primary radius" style="margin-bottom:5px;" onclick="addProduct();" href="javascript:;">
						<i class="Hui-iconfont">&#xe600;</i>添加</a>
				</div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"></label>
			<div class="formControls col-10" id="productCtn">

				
				<c:forEach items="${actTypeList}" var="goodAct" varStatus="varStatus">
					<form id="form${varStatus.count}" name="${varStatus.count}" onsubmit="return false;" action="<%=path%>/backstage/uploadImg" method="post"  enctype="multipart/form-data">
							商品${varStatus.count}：<a class="gname" id="${varStatus.count}gname" href="javascript:;">${goodAct.name}</a><a style="margin-left:320px;" class="btn btn-primary radius" onclick="sear_goods(this)" name="${varStatus.count}" href="javascript:;" title="选择货品">选择货品</a>
							<a class="btn btn-primary radius" onClick="act_disable(this,'${goodAct.actid}','${varStatus.count}')" href="javascript:;" title="删除">删除</a>
						<%-- <span class="btn-upload">
  							<a href="javascript:void();" class="btn btn-primary radius">选择图片</a>
  							<input type="file" onchange="uploadImg(${varStatus.count})" multiple name="file" class="input-file">
						</span> --%>
					</form>
					<div class="rule-con"> 
					<%-- <img class="wimg" id="simg${varStatus.count}" src="<%=imagePath%>${act.act_img }">
					活动价&nbsp;&nbsp;<input type="text" datatype="double-type" errormsg="请写正确的市场价(最多两位小数)" name="${varStatus.count}_mkt" id="${varStatus.count}_mkt_price" placeholder="活动价" value="${act.newPrice }" class="input-text" style=" width:138px;">元&nbsp;&nbsp;
					抢购量&nbsp;&nbsp;<input type="text" datatype="n" errormsg="请写正确的库存数" name="${varStatus.count}_store" id="${varStatus.count}_store" placeholder="抢购量" value="${act.count}" class="input-text" style=" width:138px;">&nbsp;&nbsp; --%>
					活动位置&nbsp;&nbsp;<input type="text" datatype="n" errormsg="请写正确的库存数" name="${varStatus.count}_sort" id="${varStatus.count}_sort" placeholder="活动位置" value="${goodAct.sort}" class="input-text" style=" width:138px;">&nbsp;&nbsp;
					原价&nbsp;&nbsp;<input type="text" readonly="readonly" datatype="double-type" errormsg="请写正确的销售价(最多两位小数)" name="${varStatus.count}_price" id="${varStatus.count}_price" placeholder="原价" value="${goodAct.price}" class="input-text" style=" width:138px;">元&nbsp;&nbsp;
					<input type="hidden" name="${varStatus.count}_productId" id="${varStatus.count}_productId" value="${goodAct.product_id}"> 
					<input type="hidden" name="${varStatus.count}_actId" id="${varStatus.count}_actId" value="${goodAct.actid}"> 
					<%-- <input type="hidden" name="${varStatus.count}_goodsId" id="${varStatus.count}_goodsId" value="${act.goods_id}">  
					<input type="hidden" id="${varStatus.count}_img" value="${act.act_img }">
					<input type="hidden" name="${varStatus.count}_gname" id="${varStatus.count}_gname" value="${act.goods_name}">--%>
					<div class="bor"></div>
					</div>
				</c:forEach>
				<c:if test="${empty actTypeList}">
					<form id="form1" name="1" onsubmit="return false;" action="<%=path%>/backstage/uploadImg" method="post"  enctype="multipart/form-data">
  							商品1:<a class="gname" id="1gname" href="javascript:;" ></a>
							<a style="margin-left:325px;" class="btn btn-primary radius" onclick="sear_goods(this)" href="javascript:;" name="1" title="选择货品">选择货品</a>
							<a class="btn btn-primary radius" onClick="deleteProductForm(this,1);" href="javascript:;" title="删除">删除</a>
						<!-- <span class="btn-upload">
							<a href="javascript:void();" class="btn btn-primary radius">选择图片</a>
  							<input type="file" onchange="uploadImg(1)" multiple name="file" class="input-file">
						</span> -->
					</form>
					<div class="rule-con" >
					<!-- <img class="wimg" id="simg1" src=""> -->
					<!-- 活动价&nbsp;&nbsp;<input type="text" datatype="double-type" errormsg="请写正确的市场价(最多两位小数)" name="1_mkt_price" id="1_mkt" placeholder="活动价" value="" class="input-text" style=" width:138px;">元 &nbsp;&nbsp;-->
					<%-- 抢购量&nbsp;&nbsp;<input type="text" datatype="n" errormsg="请写正确的库存数" name="1_store" id="1_store" placeholder="抢购量" value="${product.store}" class="input-text" style=" width:138px;"> &nbsp;&nbsp;--%>
					活动位置&nbsp;&nbsp;<input type="text" datatype="n" errormsg="请写正确的库存数" name="1_sort" id="1_sort" placeholder="活动位置" value="${product.sort}" class="input-text" style=" width:138px;">&nbsp;&nbsp;
					原价&nbsp;&nbsp;<input type="text" readonly="readonly" datatype="double-type" errormsg="请写正确的销售价(最多两位小数)" name="1_price" id="1_price" placeholder="原价" value="${product.price}" class="input-text" style=" width:138px;">元&nbsp;&nbsp;
					<input type="hidden" name="1_productId" id="1_productId" value="">
					<input type="hidden" name="1_actId" id="1_actId" value="0">
					<!-- <input type="text" name="1_goodsId" id="1_goodsId" value="">  
					<input type="text" id="1_img">
					<input type="text" name="1_gname" id="1_gname" value=""> -->
					<div class="bor"></div>
					</div>
				</c:if>
			</div>
		</div>
		</div>

		<div class="row cl">
			<div class="col-10 col-offset-2">
				<!-- <button onClick="t_goods_activity_save_submit();" class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存并提交</button> -->
				<a href="javascript:void();" onclick="submitBig();" class="btn btn-primary radius">保存并提交</a>
				<button onClick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
			</div>
		</div>
		<input type="hidden" id="size"/>
</div>
</div>
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="lib/layer/2.1/layer.js"></script> 
<script type="text/javascript" src="lib/My97DatePicker/WdatePicker.js"></script> 
<script type="text/javascript" src="lib/icheck/jquery.icheck.min.js"></script> 
<script type="text/javascript" src="lib/Validform/5.3.2/Validform.min.js"></script> 
<script type="text/javascript" src="lib/webuploader/0.1.5/webuploader.min.js"></script> 
<script type="text/javascript" src="lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" src="lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
<script type="text/javascript" src="lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" src="js/H-ui.js"></script> 
<script type="text/javascript" src="js/H-ui.admin.js"></script> 
<script type="text/javascript" src="js/jquery.form.js"></script> 
<script type="text/javascript">
$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	// 优化retina, 在retina下这个值是2
	ratio = window.devicePixelRatio || 1,
	// 缩略图大小
	thumbnailWidth = 110 * ratio,
	thumbnailHeight = 110 * ratio,
	$list = $("#fileList"),
	$btn = $("#btn-star"),
	state = "pending",
	uploader;

	var uploader = WebUploader.create({
		auto: true,
		swf: 'lib/webuploader/0.1.5/Uploader.swf',
	
		// 文件接收服务端。
		server: '<%=path%>/backstage/type-logo-upload',
	
		// 选择文件的按钮。可选。
		// 内部根据当前运行是创建，可能是input元素，也可能是flash.
		pick: '#filePicker',
	
		// 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
		resize: false,
		// 只允许选择图片文件。
		accept: {
			title: 'Images',
			extensions: 'gif,jpg,jpeg,bmp,png',
			mimeTypes: 'image/*'
		}
	});
	uploader.on( 'fileQueued', function( file ) {
		var $li = $(
			'<div id="' + file.id + '" class="item">' +
				'<div class="pic-box"><img></div>'+
				'<div class="info">' + file.name + '</div>' +
				'<p class="state">等待上传...</p>'+
			'</div>'
		),
		$img = $li.find('img');
		$list.append( $li );
	
		// 创建缩略图
		// 如果为非图片文件，可以不用调用此方法。
		// thumbnailWidth x thumbnailHeight 为 100 x 100
		uploader.makeThumb( file, function( error, src ) {
			if ( error ) {
				$img.replaceWith('<span>不能预览</span>');
				return;
			}
	
			$img.attr( 'src', src );
		}, thumbnailWidth, thumbnailHeight );
	});
	// 文件上传过程中创建进度条实时显示。
	uploader.on( 'uploadProgress', function( file, percentage ) {
		var $li = $( '#'+file.id ),
			$percent = $li.find('.progress-box .sr-only');
	
		// 避免重复创建
		if ( !$percent.length ) {
			$percent = $('<div class="progress-box"><span class="progress-bar radius"><span class="sr-only" style="width:0%"></span></span></div>').appendTo( $li ).find('.sr-only');
		}
		$li.find(".state").text("上传中");
		$percent.css( 'width', percentage * 100 + '%' );
	});
	
	// 文件上传成功，给item添加成功class, 用样式标记上传成功。
	uploader.on( 'uploadSuccess', function( file, response ) {
		$( '#'+file.id ).addClass('upload-state-success').find(".state").text("已上传");
		$("#image").val(response.datas);
	});
	
	// 文件上传失败，显示上传出错。
	uploader.on( 'uploadError', function( file ) {
		$( '#'+file.id ).addClass('upload-state-error').find(".state").text("上传出错");
	});
	
	// 完成上传完了，成功或者失败，先删除进度条。
	uploader.on( 'uploadComplete', function( file ) {
		$( '#'+file.id ).find('.progress-box').fadeOut();
	});
	uploader.on('all', function (type) {
        if (type === 'startUpload') {
            state = 'uploading';
        } else if (type === 'stopUpload') {
            state = 'paused';
        } else if (type === 'uploadFinished') {
            state = 'done';
        }

        if (state === 'uploading') {
            $btn.text('暂停上传');
        } else {
            $btn.text('开始上传');
        }
    });

    $btn.on('click', function () {
        if (state === 'uploading') {
            uploader.stop();
        } else {
            uploader.upload();
        }
    });

});

$(function(){

	$list2 = $("#fileList2"),
	$btn2 = $("#btn-star2"),
	state = "pending",
	uploader2;

	var uploader2 = WebUploader.create({
		auto: true,
		swf: 'lib/webuploader/0.1.5/Uploader.swf',
	
		// 文件接收服务端。
		server: '<%=path%>/backstage/type-logo-upload',
	
		// 选择文件的按钮。可选。
		// 内部根据当前运行是创建，可能是input元素，也可能是flash.
		pick: '#filePicker2',
	
		// 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
		resize: false,
		// 只允许选择图片文件。
		accept: {
			title: 'Images',
			extensions: 'gif,jpg,jpeg,bmp,png',
			mimeTypes: 'image/*'
		}
	});
	uploader2.on( 'fileQueued', function( file ) {
		var $li = $(
			'<div id="' + file.id + '" class="item">' +
				'<div class="pic-box"><img></div>'+
				'<div class="info">' + file.name + '</div>' +
				'<p class="state">等待上传...</p>'+
			'</div>'
		),
		$img = $li.find('img');
		$list2.append( $li );
	
		// 创建缩略图
		// 如果为非图片文件，可以不用调用此方法。
		// thumbnailWidth x thumbnailHeight 为 100 x 100
		uploader2.makeThumb( file, function( error, src ) {
			if ( error ) {
				$img.replaceWith('<span>不能预览</span>');
				return;
			}
	
			$img.attr( 'src', src );
		}, thumbnailWidth, thumbnailHeight );
	});
	// 文件上传过程中创建进度条实时显示。
	uploader2.on( 'uploadProgress', function( file, percentage ) {
		var $li = $( '#'+file.id ),
			$percent = $li.find('.progress-box .sr-only');
	
		// 避免重复创建
		if ( !$percent.length ) {
			$percent = $('<div class="progress-box"><span class="progress-bar radius"><span class="sr-only" style="width:0%"></span></span></div>').appendTo( $li ).find('.sr-only');
		}
		$li.find(".state").text("上传中");
		$percent.css( 'width', percentage * 100 + '%' );
	});
	
	// 文件上传成功，给item添加成功class, 用样式标记上传成功。
	uploader2.on( 'uploadSuccess', function( file, response ) {
		$( '#'+file.id ).addClass('upload-state-success').find(".state").text("已上传");
		$("#urlimg").val(response.datas);
	});
	
	// 文件上传失败，显示上传出错。
	uploader2.on( 'uploadError', function( file ) {
		$( '#'+file.id ).addClass('upload-state-error').find(".state").text("上传出错");
	});
	
	// 完成上传完了，成功或者失败，先删除进度条。
	uploader2.on( 'uploadComplete', function( file ) {
		$( '#'+file.id ).find('.progress-box').fadeOut();
	});
	uploader2.on('all', function (type) {
        if (type === 'startUpload') {
            state = 'uploading';
        } else if (type === 'stopUpload') {
            state = 'paused';
        } else if (type === 'uploadFinished') {
            state = 'done';
        }

        if (state === 'uploading') {
            $btn2.text('暂停上传');
        } else {
            $btn2.text('开始上传');
        }
    });

    $btn2.on('click', function () {
        if (state === 'uploading') {
            uploader2.stop();
        } else {
            uploader2.upload();
        }
    });

});
    
    /*添加*/
function sear_goods(obj) {
	$("#size").val($(obj).attr("name"));
	layer_show('选择货品', '<%=path%>/backstage/sear-act-goods-type?isone=1', 600, 500);
}

var productSize = ${productSize};
//增加商品规格
function addProduct(){
	 var $aProduct = $('<form id="form'+ (++productSize) +'" name="'+ (productSize) +'" onsubmit="return false;" method="post"  enctype="multipart/form-data">'
	 + '商品'+ (productSize) +'：<a class="gname" id="'+ (productSize) +'gname" href="javascript:;"></a>'
	 + '<a style="margin-left:325px;margin-right:5px;" class="btn btn-primary radius" name="'+productSize+'" onclick="sear_goods(this)" href="javascript:;" title="选择货品">选择货品</a>'
	 + '<a style="margin-right:5px;" class="btn btn-primary radius" onClick="deleteProductForm(this,'+ (productSize) +');" href="javascript:;" title="删除">删除</a>'
	/*  + '<span class="btn-upload">'
	 + '<a style="margin-right:5px;" href="javascript:void();" class="btn btn-primary radius">选择图片</a>'
	 + '<input type="file" onchange="uploadImg('+ (productSize) +')" multiple name="file" class="input-file"></span>' */
	 + '</form>'
	 + '<div class="rule-con">'
	 /* + '<div class="rule-con"><img class="wimg" id="simg'+ (productSize) +'" src="">'
	 + '活动价&nbsp;&nbsp;<input datatype="double-type" errormsg="请写正确的市场价(最多两位小数)" type="text" name="'+ (productSize) +'_mkt_price" id="'+ (productSize) +'_mkt" placeholder="活动价" value="" class="input-text" style=" width:138px;">元&nbsp;&nbsp; '
	 + '抢购量&nbsp;&nbsp;<input type="text" datatype="n" errormsg="请写正确的库存数" name="'+ (productSize) +'_store" id="'+ (productSize) +'_store" placeholder="抢购量" value="" class="input-text" style=" width:138px;">&nbsp;&nbsp;' */
	 + '活动位置&nbsp;&nbsp;<input type="text" datatype="n" errormsg="请写正确的库存数" name="'+ (productSize) +'_sort" id="'+ (productSize) +'_sort" placeholder="活动位置" value="" class="input-text" style=" width:138px;">&nbsp;&nbsp;'
	 + '原价&nbsp;&nbsp;<input datatype="double-type" readonly="readonly" errormsg="请写正确的销售价(最多两位小数)" type="text" name="'+ (productSize) +'_price" id="'+ (productSize) +'_price" placeholder="原价" value="" class="input-text" style=" width:138px;">'
	 + '元&nbsp;&nbsp;  '
	 + '<input type="hidden" name="'+ (productSize) +'_productId" id="'+ (productSize) +'_productId" value="">'
	 + '<input type="hidden" name="'+ (productSize) +'_actId" id="'+ (productSize) +'_actId" value="0">'
	 /*+ '<input type="hidden" name="'+ (productSize) +'_goodsId" id="'+ (productSize) +'_goodsId" value="">' 
	 + '<input type="hidden" id="'+ (productSize) +'_img">'
	 + '<input type="hidden" name="'+ (productSize) +'_gname" id="'+ (productSize) +'_gname" value=""> '*/
	 + '<div class="bor"></div>'
	 + '</div>');
	$("#productCtn").append($aProduct);
}
/*删除规格 表单*/
function deleteProductForm(form,num){
	//$(form).parent(".rule-con").next().remove();
	$("#form"+num).next().remove();
	$("#form"+num).remove();
}
/*删除规格 */
function act_disable(obj,id,num){
	layer.confirm('确认删除？', {
		btn: ['确认','取消'], 
		shade: false
	},
	function(){
		$.ajax({
			type : "POST",
			url : "<%=path%>/backstage/delGoodsActType",
			data : "id=" + id,
			error : function() {
				layer.msg('操作失败', {icon:5,time:1000});
			},
			success : function(msg) {
				layer.msg('已删除 ' + msg.information, {icon:6,time:1000});
				$("#form"+num).next().remove();
				$("#form"+num).remove();
			}
		});
	},
	function(){
		layer.msg('未删除', {icon:5,time:1000});
	});	
}
var options = {success:show,url:'<%=path%>/backstage/uploadImg'};
var options1 = {success:show1,url:'<%=path%>/backstage/addGoodsActType'};
function uploadImg(num){
	$("#form"+num).ajaxSubmit(options);
}
function show(responseText, statusText, xhr, $form){
		var imgid=$form.attr("name")+"_img";
		$("#"+imgid).val(responseText);
		$("#simg"+$form.attr("name")).attr("src",'<%=imagePath%>'+responseText);
}
function show1(responseText, statusText, xhr, $form){
	var index = parent.layer.getFrameIndex(window.name);
	parent.$('.btn-refresh').click();
	parent.layer.close(index);
		<%-- location.href="<%=path%>/backstage/t_goods_activity-list"; --%>
}

function submitBig(){
	if($("#products_list").val().length<=0){
		var products_str = "";
		var rules = $(".rule-con");
		for (var i = 0; i < rules.length; i++){
			/* products_str += $(rules[i]).find("input[id*='_mkt']").val() +",";
			products_str += $(rules[i]).find("input[id*='_price']").val()+",";
			products_str += $(rules[i]).find("input[id*='_store']").val()+","; */
			products_str += $(rules[i]).find("input[id*='_productId']").val()+",";
			products_str += $(rules[i]).find("input[id*='_actId']").val()+",";
			/* products_str += $(rules[i]).find("input[id*='_goodsId']").val()+","; */
			/* products_str += $(rules[i]).find("input[id*='_img']").val()+","; */
			products_str += $(rules[i]).find("input[id*='_sort']").val()+";";
			/* products_str += $(rules[i]).find("input[id*='_gname']").val()+";"; */
		}
		$("#products_list").val(products_str);
	}
	$("#form-t_goods_activity-add").ajaxSubmit(options1);
}
var type1;
var type2;
var type3;
function firstChange(theSelect){
	var typeId = theSelect.value;
	$("#chktypeid").val(typeId);
		$.ajax({
			type:"post",
			async:false,
			url:"<%=path%>/backstage/get-types-chil",
			data : {typeid:typeId},
			success : function(msg){
				type2 = msg;
			}
			});
	var options = "<option value=''>--中类--</option>";
	for (var i = 0; i < type2.length; i++){
		if (typeId == type2[i].cBelong){
			var aOption = "<option value='"+type2[i].cCode+"' >"+type2[i].cName+"</option>"
			options += aOption; 
		}
	}
	$("#type2").html(options);
}
function secondClick(obj){
	$("#chktypeid").val($(obj).val());
}

</script>
</body>
</html>

